<template>
	<view>
		<!-- 申购单申购 -->
		<view class="head_tb">
			<u-tabs :activeStyle="{
						 fontSize:'32rpx',
						 color: '#007aff'
			         }" :inactiveStyle="{
						 fontSize:'30rpx'
			         }" :scrollable='false' :lineWidth='30' itemStyle='height:90rpx;width:33%' :list="list1" @click="checkbtn">
			</u-tabs>
		</view>			
		<!-- 基本信息 -->
		<view class="msp">
			<CellChild :addlist='addlist' :rows='rows' title='基本信息' id='add_one' :fileNo = 'fileNo'>
				
			</CellChild>
		</view>

		<!-- 申购金额 -->
		<view>
			<CellChild :addlist='addlistv' :rows='rows' title='申购金额'>
				
			</CellChild>
		</view>

		<!-- 预算信息 -->
		<view class="formcard" id="add_two" v-if="ysxx">
			<view class="bodtitle">
				<p><b>预算信息</b></p>
			</view>
			<view v-for="(r,index) in arrcell">
				<Expandlist :cellshows='cellshow' :celllist='celllist' :arrcell='r' :title='r.budgetNo'>
					<template #text>
						<p class='solts'><label class="solts_label">
								<label style="color: #999999;font-size: 18rpx;">申请金额</label>
								￥</label><span class="solts_span" v-money>{{r.useAmt}}</span></p>
					</template>
				</Expandlist>
			</view>
		</view>

		<!-- 党工类费用明细 -->
		<view class="formcard" id="add_three" v-if="ischeck">
			<view class="bodtitle">
				<p><b>费用明细</b></p>
			</view>
			<view v-for="(item,index) in moenycell">
				<Expandlist :cellshows='cellshow' :arrcell='item' :celllist='celllist1' :title='item.serviceName'>
					<template #text>
						<p class='solts'><label class="solts_label">￥</label><span class="solts_span"
								v-money>{{item.auditMoney}}</span></p>
					</template>
				</Expandlist>
			</view>
		</view>

		<!-- 文体类费用明细 -->
		<view class="formcard" id="add_three" v-if="ischeck1">
			<view class="bodtitle">
				<p><b>费用明细</b></p>
			</view>
			<view v-for="(item,index) in moenycell">
				<Expandlist :cellshows='cellshow' :arrcell='item' :celllist='celllist1' :title='item.serviceName'>
					<template #text>
						<p class='solts'><label class="solts_label">￥</label><span class="solts_span" v-money
								>{{item.categoryTotalMoney}}</span></p>
					</template>
				</Expandlist>
			</view>
		</view>

		<!-- 一般申购单费用明细 -->
		<view class="formcard" id="add_three" v-if="ischeck2">
			<view class="bodtitle">
				<p><b>申购明细</b></p>
			</view>
			<view v-for="(item,index) in moenycell">
				<Expandlist :cellshows='cellshow' :arrcell='item' :celllist='celllist3' :title='item.serviceName'>
					<template #text>
						<p class='solts'><label class="solts_label">￥</label><span class="solts_span"
								v-money>{{item.categoryTotalMoney}}</span></p>
					</template>
				</Expandlist>
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				rows: [],
				list1: [{
						name: '基本信息',
					},
					{
						name: '预算信息'
					},
					{
						name: '费用明细'
					},
				],
				cellshow: true,
				ysxx:true,
				//申购金额
				addlistv: [{
						tit: '申请金额合计',
						val: 'applyTotalMoney',
						type:'number'
					},{
						tit: '含税金额合计',
						val: 'changeTotalMoney',
						type:'number'
					},{
						tit: '明细金额合计',
						val: 'applyCost',
						type:'number'
					},
				],
				// 党工类单元格渲染列表
				addlist: [{
						tit: '单据编号',
						val: 'budgetPurchaseNo'
					},
					{
						tit: '申购类型',
						val: 'subType'
					},
					{
						tit: '项目名称',
						val: 'theme'
					},
					// {
					// 	tit: '主题',
					// 	val: 'theme'
					// },
					
					{
						tit: '申请日期',
						val: 'applyTime'
					},
					{
						tit: '申请人',
						val: 'empName'
					},
					{
						tit: '费用承担科室',
						val: 'subdeptName'
					},
					{
						tit: '成本中心',
						val: 'costCenterDesc'
					},
					// {
					// 	tit: '科室',
					// 	val: 'subdeptName'
					// },
					{
						tit: '申请单位',
						val: 'applyCompany'
					},
					{
						tit: '活动开始时间',
						val: 'activeStartTime'
					},
					{
						tit: '活动结束时间',
						val: 'activeEndTime'
					},
					{
						tit: '费用类别',
						val: 'costType'
					},
					{
						tit: '费用明细项',
						val: 'costDetail'
					},
					// {
					// 	tit: '申请总额',
					// 	val: 'applyTotalMoney',
					// 	type: 'number'
					// },
					{
						tit: '活动人员数量',
						val: 'activistsNumber'
					},
					// {
					// 	tit: '申请费用',
					// 	val: 'applyCost',
					// 	type: 'number'
					// },
					// {
					// 	tit: '单据状态',
					// 	val: 'billStatus'
					// },

					// {
					// 	tit: '工号',
					// 	val: 'empNo'
					// },
					// {
					// 	tit: '联系电话',
					// 	val: 'telephone'
					// },
					{
						tit: '活动内容',
						val: 'oldRemarks'
					},
				],
				//申购单变更
				addlists: [
					{
						tit: '变更主题',
						val: 'theme'
					},
					{
						tit: '变更描述',
						val: 'remarks'
					}
				],
				//申购单作废
				addlistss: [
					{
						tit: '作废主题',
						val: 'theme'
					},
					{
						tit: '作废描述',
						val: 'remarks'
					}
				],
				//申购单结转
				addlistsss: [
					{
						tit: '结转主题',
						val: 'theme'
					},
					{
						tit: '结转描述',
						val: 'remarks'
					}
				],
				// 文体类单元格
				addlist1: [{
						tit: '单据编号',
						val: 'budgetPurchaseNo'
					},
					{
						tit: '申购类型',
						val: 'subType'
					},
					{
						tit: '项目名称',
						val: 'theme'
					},
					{
						tit: '申请时间',
						val: 'applyTime',
					},
					
					{
						tit: '申请人',
						val: 'empName',
					},
					{
						tit: '费用承担科室',
						val: 'subdeptName',
					},
					{
						tit: '成本中心',
						val: 'costCenterDesc',
					},
					{
						tit: '申请单位',
						val: 'applyCompany',
					},
					// {
					// 	tit: '计划预算',
					// 	val: 'isPlanBudget'
					// },
					// {
					// 	tit: '工号',
					// 	val: 'empNo'
					// },
					// {
					// 	tit: '科室',
					// 	val: 'subdeptName',
					// },
					// {
					// 	tit: '联系电话',
					// 	val: 'telephone'
					// },
					{
						tit: '活动时间',
						val: 'activeStartTime'
					},
					{
						tit: '活动人数',
						val: 'activistsNumber'
					},
					
					{
						tit: '活动地点',
						val: 'activityLocation'
					},
					{
						tit: '活动内容',
						val: 'oldRemarks'
					},
				],
				// 一般类单元格
				addlist2: [{
						tit: '单据编号',
						val: 'budgetPurchaseNo'
					},
					{
						tit: '申购类型',
						val: 'subType'
					},
					{
						tit: '项目名称',
						val: 'theme'
					},
					// {
					// 	tit: '主题',
					// 	val: 'theme'
					// },
					{
						tit: '申请时间',
						val: 'applyTime'
					},
					{
						tit: '申请人',
						val: 'empName',
					},
					{
						tit: '费用承担科室',
						val: 'subdeptName',
					},
					{
						tit: '成本中心',
						val: 'costCenterDesc',
					},
					{
						tit: '紧急程度',
						val: 'isUrgency'
					},
					{
						tit: '项目描述',
						val: 'remarks'
					},
					
					// {
					// 	tit: '申请总额',
					// 	val: 'applyTotalMoney',
					// 	type: 'number'
					// },
					// {
					// 	tit: '单据状态',
					// 	val: 'billStatus'
					// },
					
					// {
					// 	tit: '工号',
					// 	val: 'empNo'
					// },
					// {
					// 	tit: '科室',
					// 	val: 'subdeptName',
					// },
					// {
					// 	tit: '联系电话',
					// 	val: 'telephone'
					// }
				],
				//一般类费用明细
				celllist: [
					{
						tit: '预算年度',
						val: 'budgetYear'
					},
					{
							tit: '科室名称',
							val: 'subdeptNm'
						},
					{
						tit: '预算号名称',
						val: 'budgetNm'
					},
					{
						tit: '预算月份',
						val: 'budgetMonth'
					},
					{
						tit: '预算金额',
						val: 'budgetMoney',
						type: 'number'
					},
					// {
					// 	tit: '申请金额',
					// 	val: 'useAmt',
					// 	type: 'number'
					// },
					{
						tit: '月度剩余金额',
						val: 'surplusMoney',
						type: 'number'
					},
					{
						tit: '税率',
						val: 'taxRate',
					},
					{
						tit: '进项增值税',
						val: 'tax',
						type: 'number'
					},
					{
						tit: '含税总金额',
						val: 'taxMoney',
						type: 'number'
					},
				],
				//变更费用明细
				celllists: [{
						tit: '预算年度',
						val: 'budgetYear'
					},
					{
						tit: '科室名称',
						val: 'subdeptNm'
					},
					{
						tit: '预算月份',
						val: 'budgetMonth',
					},
					{
						tit: '预算号',
						val: 'budgetNo',
					},
					{
						tit: '预算号名称',
						val: 'budgetNm',
					},
					{
						tit: '预算金额',
						val: 'budgetMoney',
						type: 'number'
					},
					{
						tit: '原申请金额',
						val: 'useAmt',
						type: 'number'
					},
					{
						tit: '变更金额',
						val: 'changeAmt',
						type: 'number'
					},
					{
						tit: '变更后金额',
						val: 'changeAppmt',
						type: 'number'
					},
					{
						tit: '月度剩余金额',
						val: 'surplusMoney',
						type: 'number'
					},
					{
						tit: '税率',
						val: 'taxRate',
						type: 'bfb'
					},
					{
						tit: '进项增值税',
						val: 'tax',
						type: 'number'
					},
					{
						tit: '含税总金额',
						val: 'taxMoney',
						type: 'number'
					},
				],
				//党工类费用明细
				celllist1: [{
						tit: '物资或服务名称',
						val: 'serviceName'
					},
					{
						tit: '需要采购执行',
						val: 'isPurchaseExecute'
					},
					{
						tit: '规格',
						val: 'specs'
					},
					{
						tit: '品牌',
						val: 'brand'
					},
					{
						tit: '单价',
						val: 'unitPrice',
						type: 'number'
					},
					{
						tit: '数量',
						val: 'number'
					},
					{
						tit: '小计',
						val: 'categoryTotalMoney',
						type: 'number'
					},
				],
				//文体类类费用明细
				celllist2: [{
						tit: '内容规格',
						val: 'specs'
					},
					{
						tit: '单价',
						val: 'unitPrice',
						type: 'number'
					},
					{
						tit: '数量',
						val: 'number'
					},
					{
						tit: '小计',
						val: 'categoryTotalMoney',
						type: 'number'
					},
					{
						tit: '审核金额',
						val: 'auditMoney',
						type: 'number'
					},
				],
				arrcell: [], //预算使用明细数据
				moenycell: [], //费用明细
				wtcell: [], //文体类费用明细
				celllist3: [ //一般费用明细
					{
						tit: '规格型号',
						val: 'specs'
					},
					{
						tit: '单价',
						val: 'unitPrice',
						type: 'number'
					},
					{
						tit: '数量',
						val: 'number'
					},
					{
						tit: '推荐供货商',
						val: 'supplier'
					},
					{
						tit: '正常纳期时间',
						val: 'normalDeliveryTime'
					},
					{
						tit: '交货时间',
						val: 'deliveryTime'
					},
					{
						tit: '前期清耗',
						val: 'earlyConsume'
					},
					{
						tit: '备注',
						val: 'remarks'
					},
				],
				//变更申购明细
				celllist3s: [ //一般费用明细
					// {
					// 	tit: '品名',
					// 	val: ''
					// },
					{
						tit: '规格型号',
						val: 'specs'
					},
					{
						tit: '单价',
						val: 'unitPrice',
						type: 'number'
					},
					{
						tit: '数量',
						val: 'number'
					},
					{
						tit: '推荐供货商',
						val: 'supplier'
					},
					{
						tit: '正常纳期时间',
						val: 'normalDeliveryTime'
					},
					{
						tit: '交货时间',
						val: 'deliveryTime'
					},
					{
						tit: '前期清耗',
						val: 'earlyConsume'
					},
					{
						tit: '备注',
						val: 'remarks'
					},
				],
				ischeck: false, //党工类显示
				ischeck1: false, //文体类显示
				ischeck2: false, //一般申购单
				AppId:'',
				fileNo:''
			}
		},
		onLoad() {
			//获取流程页面的流程上下文[实用的流程信息从这里获取]
			let budgetPurchaseNo = window.parent.myvm.wfContext.BusinessKey;
			this.AppId = window.parent.myvm.wfContext.AppId
			this.fileNo = budgetPurchaseNo
			this.getlist(budgetPurchaseNo)
		},
		mounted() {
			var that = this;
			window.myvm = that;
			window.$urlFormVue = that;
		},
		methods: {
			//审批和驳回-工作流点击"提交"时触发此函数，返回:空字符串:工作流继续提交，返回"具体错误信息":工作流不提交
			rejectWorkflow(btnDef) {
				return "";
			},
			//作废-工作流点击"作废"时触发此函数，返回:空字符串:工作流继续提交，返回"具体错误信息":工作流不提交
			//content为作废意见
			invalidWorkflow(content) {
				return "";
			},
			//转办-工作流点击"确认转办"时触发此函数，返回:空字符串:工作流继续提交，返回"具体错误信息":工作流不提交
			//opinion:转办意见
			referredWorkflow(opinion) {
				return "";
			},
			//校验-工作流点击"提交"时触校验函数，返回:true校验通过，false校验不通过；
			//也可以返回具体的错误信息：空字符串，校验通过，返回具体错误信息校验不通过，同时弹出具体的错误信息。
			validateWorkflowForm(btnDef,callback) {
				callback("");
			},
			//提交单据
			sendWorkflow(btnDef, callback) {
				callback("");
			},
			getlist(budgetPurchaseNo) {
				let _this = this
				const params = {
					budgetPurchaseNo
				}
				_this.$lyRequest.get('/gateway/budget/mp/dbsap/budget/budgetPurchase/getBudgetPurchase.do',
					params
				).then((result) => {
					if (result.success) {
						this.rows = result.data.rows
						this.arrcell = result.data.rows.budgetUsedEntities
						this.moenycell = result.data.rows.buBudgetPDetailsEntities
						
						this.changelist()
					} else {
						console.log('网络出错')
					}
				})
			},
			changelist() {
				// 申购类型
				switch (this.rows.subType) {
					case '2':
						this.rows.subType = '党工类'
						this.ischeck = true
						break;
					case '3':
						this.rows.subType = ' 文体类'
						this.addlist = this.addlist1
						this.list1[1].name = '预算信息'
						this.list1[2].name = '费用明细'
						this.ischeck1 = true
						break;
					case '1':
						this.rows.subType = '一般类'
						this.addlist = this.addlist2
						this.list1[2].name = '申购明细'
						this.ischeck2 = true
						break;
				}
				//是否采购执行
				for(let i=0;i<this.moenycell.length;i++){
					if(this.moenycell[i].isPurchaseExecute == '1'){
						this.moenycell[i].isPurchaseExecute = '是'
					}else{
						this.moenycell[i].isPurchaseExecute = '否'
					}
				}
				if (this.AppId == 'AT') {
					//一般申购单变更
					this.addlist = this.addlist.concat(this.addlists)
					// this.ysxx = false //隐藏预算信息
				} else if (this.AppId == 'AU') {
					//一般申购单作废
					this.addlist = this.addlist.concat(this.addlistss)
				} else if (this.AppId == 'AM') {
					//一般申购单结转
					 //基本信息
					this.addlist = this.addlist.concat(this.addlistsss)
				}
				
				// 计划预算
				switch (this.rows.isPlanBudget) {
					case 'true':
						this.rows.isPlanBudget = '是'
						break;
					case 'false':
						this.rows.isPlanBudget = '否'
						break;
				}
			
				//单据状态
				switch (this.rows.billStatus) {
					case '0':
						this.rows.billStatus = ' 草稿'
						break;
					case '1':
						this.rows.billStatus = ' 正常'
						break;
					case '2':
						this.rows.billStatus = '审批中'
						break;
					case '3':
						this.rows.billStatus = '冻结'
						break;
					case '4':
						this.rows.billStatus = '作废'
						break;
				}
				//费用类别
				switch (this.rows.costType) {
					case '1':
						this.rows.costType = '党员活动费'
						break;
					case '2':
						this.rows.costType = '党委活动费'
						break;
					case '3':
						this.rows.costType = '团委活动费'
						break;
					case '4':
						this.rows.costType = '纪检监察活动费'
						break;
				}
				//费用明细项
				switch (this.rows.costDetail) {
					case '1':
						this.rows.costDetail = '教育培训'
						break;
					case '2':
						this.rows.costDetail = '组织生活'
						break;
					case '3':
						this.rows.costDetail = '宣传活动'
						break;
					case '4':
						this.rows.costDetail = '其他团队活动'
						break;
				}
				
			},
			checkbtn(item) { //切换tabs
				switch (item.index) {
					case 0:
						this.commonApi.goAnchor('add_one')
						break
					case 1:
						this.commonApi.goAnchor('add_two')
						break
					case 2:
						this.commonApi.goAnchor('add_three')
						break
				}
			},
			getpast() {

			}
		}
	}
</script>

<style scoped lang="scss">
	view {
		font-family: pf;
	}

	.bodcolor {
		span {
			color: #ff6400;
			font-size: 36rpx;
			padding-right: 20rpx;
		}

		label {
			color: #ff6400;
		}
	}

	.bottom_setup {
		width: 100%;
		height: 160rpx;
		background-color: white;
		margin-top: 20rpx;
		padding: 35rpx 0;
		box-sizing: border-box;
		box-shadow: 5px -10rpx 5px 0px rgba(225, 225, 225, .4), ;

		.bottom_white1 {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			height: 100rpx;

			.custom-styles {
				padding: 20rpx 30rpx;
				width: 300rpx;
				height: 100rpx;
			}

			.custom-style {
				padding: 20rpx 30rpx;
				width: 300rpx;
				height: 100rpx;
				background-color: #007aff;
			}
		}
	}
</style>
